import java.util.Arrays;

public class rotate {
    /**
     * 轮转数组
     * 给定一个整数数组nums，将数组中的元素向右轮转k个位置，其中的k代表的是非负数
     *
     */
    public static void method(int[] nums, int k){
        k%= nums.length;
        reverse(nums,0, nums.length-1);
        reverse(nums, 0 ,k-1);
        reverse(nums, k, nums.length - 1);

    }
    public static void reverse(int[] nums, int start, int end){
        while (start < end){
            int temp = nums[start];
            nums[start] = nums[end];
            nums[end] = temp;
            start++;
            end--;
        }
    }

    public static void main(String[] args) {
    int [] nums={1,2,3,4,5,6,7};
    int k=3;
    method(nums, k);
        System.out.println(Arrays.toString(nums));
    }
}
